﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Text;

namespace PeisongWeb.admin
{
    public partial class myCustomerList : adminPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (hasPermission("IB", 1))
                {
                    rptBind();
                }
                else
                {
                    Library.Script.ClientMsgUrl("没有权限！", "index.aspx");
                    return;
                }
            }
        }

        void rptBind()
        {
            StringBuilder where = new StringBuilder();
            where.Append("type='2' and isCheck=1 and salesperson="+logic.sysAdmin.AdminID);
            if (txt_companyName.Text.Trim() != "")
                where.AppendFormat("and company like '%{0}%'", txt_companyName.Text.Trim());
            if (txt_mobile.Text.Trim() != "")
                where.AppendFormat("and mobile = '{0}'", txt_mobile.Text.Trim());
            DataSet ds = logic.company.select(where.ToString(), "companyId desc", AspNetPager1.PageSize, AspNetPager1.CurrentPageIndex);
            AspNetPager1.RecordCount = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
            rpt_list.DataSource = ds.Tables[1];
            rpt_list.DataBind();
        }

        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            rptBind();
        }
        protected void lbtn_Search_Click(object sender, EventArgs e)
        {
            rptBind();
        }
    }
}
